package com.yxy.mapper;

import com.github.pagehelper.Page;
import com.yxy.pojo.dto.HotelBookingPageQueryDTO;
import com.yxy.pojo.entity.HotelBooking;
import com.yxy.pojo.entity.SightsBooking;
import com.yxy.pojo.vo.HotelBookingPageQueryVO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

@Mapper
public interface HotelBookingMapper {

    /**
     * 获取所有
     * @return
     */
    @Select("select * from hotel_booking")
    List<Integer> getAll();

    /**
     * 添加
     * @param hotelBooking
     */
    void add(HotelBooking hotelBooking);

    /**
     * 分页查询
     * @param hotelBookingPageQueryDTO
     * @return
     */
    Page<HotelBookingPageQueryVO> pageQuery(HotelBookingPageQueryDTO hotelBookingPageQueryDTO);

    /**
     * 修改状态
     * @param build
     */
    void updateStatus(HotelBooking build);

    /**
     * 分页查询
     * @param hotelBookingPageQueryDTO
     * @return
     */
    @Select("select * from hotel_booking where user_id = #{userId} and status = #{status}")
    Page<HotelBookingPageQueryVO> pageQueryHotelBooking(HotelBookingPageQueryDTO hotelBookingPageQueryDTO);

    /**
     * 根据id查询
     * @param id
     * @return
     */
    @Select("select * from hotel_booking where id = #{id}")
    HotelBooking selectById(Integer id);

    /**
     * 修改
     * @param build
     */
    void update(SightsBooking build);

    /**
     * 查询列表
     * @return
     */
    @Select("select h.*, u.name from hotel_booking h left join user u on h.user_id = u.id")
    List<HotelBookingPageQueryVO> selectList();
}
